import CreepController from "../controller"


class RoleAttacker {

    /**
     *
     * @param creep
     * @returns
     */
    static loop(creep: Creep) {
        const roomName: string = 'E38S52'
        const room = Game.rooms[roomName]
        if (!room || room.name != creep.room.name) {
            creep.goTo(new RoomPosition(25, 25, roomName))
            return null
        }
        else {
            var hostiles = creep.room.find(FIND_HOSTILE_CREEPS);
            if (hostiles.length == 0) {
                creep.goTo(new RoomPosition(33, 33, roomName))
                return
            }
            else {
                for (const name in hostiles) {
                    const hostile = hostiles[name]
                    var username = hostile.owner.username;
                    if (username == 'superbitch') {
                        continue
                    }
                    creep.goTo(hostile.pos)
                    // creep.attack(hostile)
                    creep.rangedAttack(hostile)
                }
            }
        }
    }
}

export default RoleAttacker
